//
//  PublishFriendContentVC.m
//  LyhToolsTest
//
//  Created by daojial on 2019/8/23.
//  Copyright © 2019 LYH.com. All rights reserved.
//

#import "PublishFriendContentVC.h"
#import "ZJScrollPageView.h"

#import "ChooseContentVC.h"
#import "ChooseImageVC.h"



@interface PublishFriendContentVC ()<ZJScrollPageViewDelegate>
@property (strong, nonatomic) NSArray<NSString *> *titles;
@property (nonatomic, strong) ZJScrollPageView *scrollPageView;
@end
@implementation PublishFriendContentVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self initNava];
    [self initUI];
}
-(void)initNava
{
    WeakSelf;
    wself.ts_navgationBar = [TSNavigationBar navWithTitle:@"霸屏神器" backAction:^{
        [self.navigationController popViewControllerAnimated:YES];
    }];
}
- (void)initUI
{
    [self scrollPageView];
    
}
#pragma ZJScrollPageViewDelegate 代理方法
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
    
    if (!childVc) {
        if (index==0) {
            childVc = [[ChooseImageVC alloc] init];
            ChooseImageVC *vc = (ChooseImageVC *)childVc;
             return vc;
        } else {
            childVc = [[ChooseContentVC alloc] init];
            ChooseContentVC *vc = (ChooseContentVC *)childVc;
            return vc;
        }
        
    }
    return childVc;
}
- (ZJScrollPageView *)scrollPageView
{
    if (!_scrollPageView) {
        ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
        //显示滚动条
        style.showLine = YES;
        // 颜色渐变
        style.gradualChangeTitleColor = YES;
        style.autoAdjustTitlesWidth = YES;
        
        // 初始化
        _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0,SafeAreaTopHeight, self.view.bounds.size.width, self.view.bounds.size.height - SafeAreaTopHeight) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
        
        [self.view addSubview:_scrollPageView];
    }
    return _scrollPageView;
}
- (NSArray<NSString *> *)titles
{
    if (!_titles) {
        _titles = @[@"朋友圈配图", @"朋友圈配文"];
    }
    return _titles;
}

@end
